#include "manip.hpp"
#include "yocto/math/io/data-set.hpp"
#include "yocto/ios/icstream.hpp"
#include <cmath>
#include "yocto/exception.hpp"

Manip:: ~Manip() throw()
{
}

Manip:: Manip( const string &input_file ) :
t(),
pH(),
h()
{
    math::data_set<double> ds;
    ds.use(1, t);
    ds.use(2, pH);
    ios::icstream fp( input_file );
    ds.load( fp );
    const size_t n = pH.size();
    
    if( n < 2 )
        throw exception("not enough data in '%s'", input_file.c_str() );
    
    h.make(n,0.0);
    for( size_t i=1; i <= n; ++i )
    {
        h[i] = pow( 10.0, -pH[i] );
        t[i] *= 60.0;
    }
}
